package com.ruoyi.gift.service.impl;

import com.ruoyi.gift.domain.dto.StatsQueryDTO;
import com.ruoyi.gift.domain.vo.MaintenanceStatsVO;
import com.ruoyi.gift.domain.vo.MaintenanceSummaryVO;
import com.ruoyi.gift.domain.vo.StatsResultVO;
import com.ruoyi.gift.mapper.RoadSignMaintenanceMapper;
import com.ruoyi.gift.mapper.RoadSignMapper;
import com.ruoyi.gift.service.IRoadSignStatsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoadSignStatsServiceImpl implements IRoadSignStatsService {

    @Autowired
    private RoadSignMapper roadSignMapper;

    @Autowired
    private RoadSignMaintenanceMapper roadSignMaintenanceMapper;

    @Override
    public List<StatsResultVO> getRoadSignCountStats(StatsQueryDTO queryDTO) {
        if ("street".equals(queryDTO.getStatsType())) {
            return roadSignMapper.countByStreet();
        } else if ("road".equals(queryDTO.getStatsType())) {
            return roadSignMapper.countByRoadName();
        } else {
            // 默认按街道统计
            return roadSignMapper.countByStreet();
        }
    }

    @Override
    public List<MaintenanceStatsVO> getMaintenanceStats(StatsQueryDTO queryDTO) {
        return roadSignMaintenanceMapper.selectMaintenanceStats(queryDTO);
    }

    @Override
    public MaintenanceSummaryVO getMaintenanceSummary(StatsQueryDTO queryDTO) {
        return roadSignMaintenanceMapper.selectMaintenanceSummary(queryDTO);
    }
}